package com.heima.kafka.boot.listener;

import com.alibaba.fastjson.JSON;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 消费者监听类
 */
@Component
public class ConsumerListener {
    /***
     * 监听订阅当前topic
     */
    @KafkaListener(topics = {"boot-topic"})
    public void getMessage(String message){
        //对字符串类型转化类型map
        Map map = JSON.parseObject(message, Map.class);
        System.out.println("监听到的消息内容:"+map.get("name"));
    }
}












